package com.example.liyuehui.dsldemo;

import org.gradle.api.DefaultTask;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputDirectory;
import org.gradle.api.tasks.TaskAction;

/**
 * @author LiYueHui
 * @date 17-12-7 下午4:56
 */

public class DumpTask extends DefaultTask {

	public MyExtension getExtension() {
		return extension;
	}

	@Input
	public void setExtension(MyExtension extension) {
		this.extension = extension;
	}


	private MyExtension extension;

	public DumpTask() {
	}

	@TaskAction
	public void dump() {
		System.out.println("extension name:" + extension.getExtensionName());
		InnerExtension innerExtension = extension.getInnerExtension();

		System.out.println("innerExtension:" + innerExtension.getInnerName());

		NamedDomainObjectContainer<SmallExtension> container = extension.getSmallExtensions();
		int size = container.size();
		System.out.println("countainer size:" + size);
		container.forEach(smallExtension -> {
			System.out.printf("name:%s smallName:%S", smallExtension.getName(), smallExtension.getSmallName());
			System.out.println("");
		});

	}
}
